package com.csd.base;

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;

public abstract class BaseFragment extends Fragment implements OnClickListener {
	protected Context mContext;     
	public View rootView;
	
	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
		initData(savedInstanceState);
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		mContext = getActivity();
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		rootView  = initView(inflater);
		findViewById();
		setListener();
		return rootView;
	}
	public View getRootView(){
		return rootView;
	}
	
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		
	}
	
	/**
	 * 加载进fragment的view
	 * @param inflater
	 * @return 返回要显示的view
	 */
	protected abstract View initView(LayoutInflater inflater);

	/**
	 * 查找子view的id
	 */
	protected abstract void findViewById();
	
	/**
	 * 设置监听事件
	 */
	protected abstract void setListener();
	
	/**
	 * 初始加载数据
	 * @param savedInstanceState
	 */
	protected abstract void initData(Bundle savedInstanceState);
	
	
	/**
	 * 刷新数据
	 */
	public void processData() {
		
	}
	
	/**
	 * fragment状态切换时调�?
	 */
	public void onScrolling() {
		
	}
	
}
